#include "AffineTransform.h"
#include "MathDefine.h"

#include <math.h>

AffineTransform::AffineTransform(void)
: m_translation( 0, 0, 0 )
, m_rotation( 0, 0, 0, 1 )
, m_scale( 1, 1, 1 )
{
}

AffineTransform::AffineTransform( Vector3 & translation, Quaternion & rotation, Vector3 & scale )
: m_translation( translation )
, m_rotation( rotation )
, m_scale( scale )
{
}

AffineTransform::~AffineTransform(void)
{
}

void AffineTransform::GetMatrix( Matrix & result )
{
	D3DXMatrixRotationQuaternion( &result, &m_rotation );

	Vector3 & row0 = *(Vector3*)(result.m[0]);
	Vector3 & row1 = *(Vector3*)(result.m[1]);
	Vector3 & row2 = *(Vector3*)(result.m[2]);
	Vector3 & row3 = *(Vector3*)(result.m[3]);

	row0 *= m_scale.x;
	row1 *= m_scale.y;
	row2 *= m_scale.z; 

	row3 = m_translation;
}
